package edu.gatech.cs4220;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;

public class ProfileName extends Activity {
	static final String NEW_PROFILE_NAME = "edu.gatech.cs4220.newName";
	private String newName;
	private EditText name;
	private LocationProfileSet profiles;
	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.profilename);
		Bundle bun = getIntent().getExtras();
		profiles = (LocationProfileSet)bun.get(ProfileList.PROFILES_SET);
		name = (EditText)findViewById(R.id.widget39);
	}
	
	public void cancelButton(View view)
	{
		//TODO This is what happens when you click "cancel" it should end the current activity
		finish();
	}
	
	public void saveButton(View view)
	{
		newName = name.getText().toString();
		LocationProfile newProf = new LocationProfile(getApplicationContext(),newName);
		profiles.addProfile(newProf);
		//TODO This should move to the next screen and create a new profile based on what is in the editText field
		Intent myIntent = new Intent(view.getContext(), EditProfile.class);
		myIntent.putExtra(ProfileList.PROFILES_SET, profiles);
		myIntent.putExtra(ProfileName.NEW_PROFILE_NAME,newName);
		myIntent.putExtra(EditProfile.PROFILE_TO_EDIT,newProf);
		startActivityForResult(myIntent, 0);
	}
}
